#ifndef     _PING_H_
#define     _PING_H_

#include "RawSocket.h"
#include "ErrMsgPro.h"


#if 0
#define IPPROTO_IP              0               /* dummy for IP */
#define IPPROTO_ICMP            1               /* control message protocol */
#define IPPROTO_IGMP            2               /* group management protocol */
#define IPPROTO_GGP             3               /* gateway^2 (deprecated) */
#define IPPROTO_TCP             6               /* tcp */
#define IPPROTO_PUP             12              /* pup */
#endif


int     sockfd;

void init_v6(void);
void init_v4(void);
void proc_v4(char*, ssize_t, struct msghdr*, struct timeval *);
void proc_v6(char*, ssize_t, struct msghdr*, struct timeval *);
void send_v4(void);
void send_v6(void);
void readloop(void);
void sig_alarm(int);
void tv_sub(struct timeval*, struct timeval*);
uint16_t in_cksum(uint16_t *addr, int len);

struct PingProto
{
    void (*fproc)(char*, ssize_t, struct msghdr*, struct timeval*);
    void (*fsend)(void);
    void (*finit)(void);
    struct sockaddr *sasend;
    struct sockaddr *sarecv;
    socklen_t salen;
    int icmpproto;
}*pr;

#ifdef     IPV6
#include <netinet/ip6.h>
#include <netinet/icmp6.h>
#endif //IPV6

#endif //_PING_H_